import { defineStore } from "pinia";
import { computed, reactive, ref } from "vue";

import { setToken } from "@/utils/auth.ts";

import {
  bookApi,
  searchBookApi,
  cancelBookApi,
  showDateDetailApi,
  selectmettingNameApi,
} from "@/api/calendar.ts";

export const useCalendarStore = defineStore("calendar", () => {
  //state

  //getters

  //action
  // 会议预约
  const book = async (params: {
    userUuid: string;
    meetingName: string;
    meetingDates: Array<string>;
  }) => {
    let result = await bookApi(params);
    return result;
  };
  // 会议列表查询
  const searchBook = async (params: {
    userUuid: string;
    startDate: string;
    endDate: string;
  }) => {
    let result = await searchBookApi(params);
    return result;
  };

  // 用户取消预约
  const cancelBook = async (params: {
    userUuid: string;
    meetingDates: Array<string>;
  }) => {
    let result = await cancelBookApi(params);
    return result;
  };

  // 会议名称查询
  const selectmettingName = async () => {
    let result = await selectmettingNameApi();
    return result;
  };

  // 点击人数展示详情(日期详情展示)
  const showDateDetail = async (params: { meetingDates: Array<string> }) => {
    let result = await showDateDetailApi(params);
    return result;
  };

  return {
    book,
    searchBook,
    cancelBook,
    showDateDetail,
    selectmettingName,
  };
});
